package dao.Impl;

import commons.druidJdbcUtil;
import dao.DeletUserDao;
import pojo.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DeletUserDaoImpl implements DeletUserDao {
    @Override
    public void deletUser(int userid) {
        Connection conn=null;
        PreparedStatement ps=null;

        try {
            conn= druidJdbcUtil.getConnection();
            conn.setAutoCommit(false);
            ps=conn.prepareStatement("delete from users where userid=?");
            ps.setInt(1,userid);
            ps.execute();
            conn.commit();
        }catch (Exception e){
            e.printStackTrace();
            druidJdbcUtil.roolback(conn);
        }finally {
            druidJdbcUtil.closeResource(conn,ps);
        }
    }
}
